package cn.edu.xmu.restfuldemo.model.VO;

import cn.edu.xmu.restfuldemo.model.BO.Product;
import cn.edu.xmu.restfuldemo.model.PO.GoodsPo;
import cn.edu.xmu.restfuldemo.model.PO.ProductPo;
import cn.edu.xmu.restfuldemo.model.VoObject;
import lombok.*;

import java.time.LocalDateTime;

/**
 * @author RenJieZheng
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ProductVo implements VoObject {
    private Long id;
    private Long goodsId;
    private String productSn;
    private String name;
    private Long originalPrice;
    private Long weight;
    private String imageUrl;
    private Byte state;
    private String detail;
    private Byte disabled;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;

    public ProductVo(ProductPo productPo) {
        this.id = productPo.getId();
        this.name = productPo.getName();
        this.goodsId = productPo.getGoodsId();
        this.productSn = productPo.getProductSn();
        this.originalPrice = productPo.getOriginalPrice();
        this.weight = productPo.getWeight();
        this.state = productPo.getState();
        this.detail = productPo.getDetail();
        this.imageUrl = productPo.getImageUrl();
        this.disabled = productPo.getDisabled();
        this.gmtCreate = productPo.getGmtCreate();
        this.gmtModified = productPo.getGmtModified();
    }

    /**
     * Product->ProductPo
     * @return
     */
    public Product newProduct(){
        Product product = new Product();
        product.setId(this.id);
        product.setGoodsId(this.goodsId);
        product.setProductSn(this.productSn);
        product.setName(this.name);
        product.setOriginalPrice(this.originalPrice);
        product.setWeight(this.weight);
        product.setState(this.state);
        product.setDetail(this.detail);
        product.setImageUrl(this.imageUrl);
        product.setDisabled(this.disabled);
        product.setGmtCreate(this.gmtCreate);
        product.setGmtModified(this.gmtModified);
        return product;
    }

    @Override
    public Object createVo() {
        return this;
    }

    @Override
    public Object createSimpleVo() {
        return this;
    }
}
